<?php

namespace App\Http\Middleware;

use App\Http\Controllers\Controller;
use App\Modules\User\Services\UserService;
use Closure;

class LoginVerify
{
    /**
     * 判断是否后台是否登录.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {

//        $uid = $request->session()->get('uid');
//        if(!$uid){
//            return redirect()->action('\App\Admin\Controllers\LoginController@login')->withInput();
//        }
        $user = Controller::getAuthenticatedUser();
        if($user === false) {
            return response()->error('NOT_LOGIN');
        }
        $response = $next($request);
        return $response;
    }
}
